//该页面-主要配置各个用到的echart图表信息

//新增确诊TOP10
export function setOption1(countryAddConfirmRankList){
	let yAxis =[];
	let xAxis=[];
	for (let val of countryAddConfirmRankList) {
		xAxis.push(val.nation);
		yAxis.push(val.addConfirm);
	}
	let option1 = {
		color: ["#2f89cf"],
		tooltip: {
			trigger: "axis",
			axisPointer: {
				// 坐标轴指示器，坐标轴触发有效
				type: "shadow" // 默认为直线，可选为：'line' | 'shadow'
			}
		},
		// 修改图表的大小
		grid: {
			left: "0%",
			top: "10px",
			right: "3%",
			bottom: "4%",
			containLabel: true
		},
		xAxis: [{
			type: "category",
			data:xAxis,
			axisTick: {
				alignWithLabel: true
			},
			// 修改刻度标签 相关样式
			axisLabel: {
				color: "rgba(255,255,255,.6) ",
				fontSize: "10"
			},
			// 不显示x坐标轴的样式
			axisLine: {
				show: false
			}
		}],
		yAxis: [{
			type: "value",
			// 修改刻度标签 相关样式
			axisLabel: {
				color: "rgba(255,255,255,.6) ",
				fontSize: 10
			},
			// y轴的线条改为了2像素
			axisLine: {
				lineStyle: {
					color: "rgba(255,255,255,.1)",
					width: 2
				}
			},
			// y轴分割线的颜色
			splitLine: {
				lineStyle: {
					color: "rgba(255,255,255,.1)"
				}
			}
		}],
		series: [{
			name: "新增确诊",
			type: "bar",
			data:yAxis,
			barWidth: "35%",
			itemStyle: {
				barBorderRadius: 5
			}
		}]
	}
	return option1	
}
//主要国家治愈率-参考图表https://www.makeapie.com/editor.html?c=xkwL0ooeD-
export function setOption2(foreignList){
	let yAxis =[];
	let xAxis=[];
	var myColor = ['#21BF57','#56D0E3',  '#1089E7', '#F8B448','#F57474', ];
	for (let val of foreignList) {
		let percent=parseInt(val.heal/val.confirm*100)
		xAxis.push(val.name);
		yAxis.push(percent);
	}
    xAxis=xAxis.splice(0,5)

	let option2 = {
		grid: {
			left: '15%',
			right: '5%',
			bottom: '5%',
			top: '10%',
			containLabel: true
		},
		xAxis: {
			show: false,
			type: 'value'
		},
		yAxis: [{
			type: 'category',
			inverse: true,
			axisLabel: {
				show: true,
				textStyle: {
					color: '#fff'
				},
			},
			splitLine: {
				show: false
			},
			axisTick: {
				show: false
			},
			axisLine: {
				show: false
			},
			// data: ['大米', '玉米', '蔬菜', '鸡蛋', '坚果']
			data:xAxis
		}],
		series: [{
				name: '金额',
				type: 'bar',
				zlevel: 1,
				itemStyle: {
					normal: {
						borderColor: '#4DCEF8',
						borderWidth: 2,
						barBorderRadius: 15,
						color: 'rgba(102, 102, 102,0)'
					},
				},
				barWidth: 20,
				data: [100, 100, 100, 100, 100],
				
			},
			
			{
				type: 'bar',
				barGap: '-85%',
				barWidth: '50%',
				itemStyle: {
					 normal: {
						barBorderRadius: 16,
						color: function(params) {
							var num = myColor.length;
							return myColor[params.dataIndex % num]
						},
					}
				},
				max: 1,
				label: {
					normal: {
						show: true,
						position: 'inside',
						formatter: '{c}%'
					}
				},
				labelLine: {
					show: true,
				},
				z: 2,
				data:yAxis
			}
		]
	};
	return option2				
}
//大洲感染总人数趋势图
export function setOption3(continentStatis){

}
//世界每周新增治愈和死亡人数
export function setOption4(globalDailyHistory){

}
//大洲感染人数饼状图
export function setOption5(continentStatisNow){
	
}
//境外输入病情top10省份
export function setOption6(importStatis){
	

}
//世界疫情图
export function worldMapOption(){
	let option = {
		    // 设置提示信息
		    tooltip: {
		        // 设置提示信息触发源
		        trigger: 'item',
		        // 设置提示信息格式
		        formatter: function (params) {
		            return params.name + " : " + (params.value ? params.value : 0);
		        }
		    },
		    // 视觉映射组件
		    visualMap: {
		        // 设置映射类型：piecewise分段型、continuous连续性
		        type: 'piecewise',
		        pieces: [
		            { max: 0, label: '0', color: '#eee' },
		            { min: 1, max: 499, label: '1-499', color: '#fff7ba' },
		            { min: 500, max: 4999, label: '500-4999', color: '#ffc24b' },
		            { min: 5000, max: 9999, label: '5000-9999', color: '#ff7c20' },
		            { min: 10000, max: 100000, label: '1万-10万', color: '#fe5e3b' },
		            { min: 100000, max: 500000, label: '10万-50万', color: '#e2482b' },
		            { min: 500000, label: '50万以上', color: '#b93e26' },
		        ],
		        itemHeight: 10,
		        itemWidth: 10,
		        inverse: true,
				bottom:"20%",
				textStyle: {
				  color: "rgba(255,255,255,.5)",
				  fontSize: "12"
				}
		    },
		    // 系列列表
		    series: [{
		        // 数据名称
		        name: '',
		        // 设置数据
		        data: '',
		        // 绘制的图表类型
		        type: 'map',
		        // 指定地图名称
		        mapType: 'world',
		        // 地区名称映射
		        nameMap: '',
		        // 图表所绘制区域样式
		        itemStyle: {
		            emphasis: {
		                areaColor: '#c9ffff',
		                label: {
		                    show: false
		                }
		            }
		        },
		        // 设置位置：保持地图高宽比的情况下把地图放在容器的正中间
		        layoutCenter: ['48%','50%'],
		        // 地图缩放
		        layoutSize: "80%",
		    }]
		};
	return option
}
//获取国外累计确诊和现存确诊数据-遍历国外数据disease_foreign
export function setForeignData(foreignList){
	let confirmData = [];
	let nowConfirmData = [];
	let foreignData = {};
	for(let value of foreignList){
		confirmData.push({name:value.name,value:value.confirm})
		nowConfirmData.push({name:value.name,value:value.nowConfirm})
	}
	foreignData = {confirmData,nowConfirmData}
	return foreignData
}